package com.kyub.buganville

import grails.test.*

class ArtifactTests extends GrailsUnitTestCase {
    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testSave() {
     def user = new User(username: 'me', enabled: true, password: 'password')
     mockDomain(User,[user])
     def artifact = new Artifact(name:"demo artifact" , description:"Demo demo demo")
     mockDomain(Artifact,[artifact])

     Artifact aOk =  new Artifact(name:"demo artifact" , description:"Demo demo demo")
     if(aOk.validate()){
        aOk.save()
        assertNotNull(aOk.id)
        assertNotNull(aOk.dateCreated)
       aOk.addToOwners(user)
       aOk.save()
      } else{
       println(aOk.errors )
       fail("Validation fails")
     }

      Artifact aNoLenght =  new Artifact(name:"demo" , description:"Demo demo demo")

      assertFalse(aNoLenght.validate())


    }
}
